package com.xinxin.o2o.enums;

/**
 * @author 史鑫鑫
 * @date 2019-08-13 22:59
 */
public enum ShopStateEnum {
    /**
     * 店铺状态
     */
    CHECK(0, "审核中"),
    OFFLINE(-1, "非法店铺"),
    SUCCESS(1, "操作成功"),
    PASS(2, "通过认证"),
    INNER_ERROR(-1001, "内部系统错误"),
    NULL_SHOPID(-1002, "ShopId为空"),
    NULL_SHOP(-1003, "Shop为空"),
    ILLEGAL_ARGUMENT(-2001, "非法参数");

    private Integer state;
    private String stateInfo;

    ShopStateEnum(Integer state, String stateInfo) {
        this.state = state;
        this.stateInfo = stateInfo;
    }

    public Integer getState() {
        return state;
    }

    public String getStateInfo() {
        return stateInfo;
    }

    /**
     * 根据传入的状态值返回状态
     *
     * @param state 状态
     * @return 状态枚举
     */
    public static ShopStateEnum stateOf(Integer state) {
        for (ShopStateEnum stateEnum : values()) {
            if (stateEnum.getState().equals(state)) {
                return stateEnum;
            }
        }
        return null;
    }
}
